
<cfset BASE = CreateObject("component", "#session.rootDir#.cfc.base") />
<cfset mainQueries = CreateObject("component", "#session.rootDir#.cfc.queries") />
<cfset termQueries = CreateObject("component", "#session.rootDir#.cfc.terminationQueries") />
<cfset statusQueries = CreateObject("component", "#session.rootDir#.cfc.statusQueries") />
<cfset term = CreateObject("component", "#session.rootDir#.cfc.Termination") />
<cfinclude template="/code_lib/SCF_Employee.cfm">
<cfinclude template="/code_lib/SCF_HR.cfm">
<cfinclude template="/code_lib/SCF_REGEX.cfm">
<cfoutput>
<!---HTML header, css links, js links, and page title--->
#BASE.htmlTerminationHeader(
    "", <!---JS links--->
    "", <!---CSS links--->
    "Scheduled Archived Users Folder Termination", <!---Page Title--->
    "Status" <!---Active Nav Link--->
)#
<!---HTML header, css links, js links, and page title--->

       
<cfif (Session.bolAuth EQ True and (Session.strAuthType EQ Session.IT OR Session.strAuthType EQ Session.HR OR Session.strUserID EQ Session.SERVICE_ACCOUNT))>   

    <cfset QUERIES.getOUArchiveFolderTermSchedule = termQueries.funcGetOUArchiveFolderTermSchedule(  ) />
    
    <Cfquery dbtype="query" name="QUERIES.ScheduledFolderTerm">
        SELECT * FROM QUERIES.getOUArchiveFolderTermSchedule
        WHERE DeleteDate <= '#DateFormat( Now(), "m/d/yyyy" )#'
    </cfquery>
    
    <cfset summary = "" />
        
    <cfloop query="QUERIES.ScheduledFolderTerm">    
        <cftry>        
            <cfsetting enablecfoutputonly="true">
            
            <cfset summary &= "<strong>UserDN:</strong> #ArchivedFolder# <br /> <strong>Deleted:</strong> #DateFormat( Now(), 'm/d/yyyy' )#<hr /><br /><br />" />                                    
            
            
            <cfcatch type="any">                
                <cfmail to=#Session.ITS_EMAIL# From="EPAR_Error@scf.cc" subject="ERROR: EPAR Archived Users Folder Termination Summary" type="html">
                    <strong>An error has occured during the deletion of archived users.  Review the error below.</strong><br /><br />
                    <strong>Error Message:</strong> #CFCATCH.message#<br />
                    <strong>Error Detail:</strong> #CFCATCH.detail#                    
                </cfmail>                                                    
            </cfcatch>
        </cftry>        
    </cfloop>

    <cfmail to=#Session.ITS_EMAIL# From="EPAR_Scheduled@scf.cc" subject="EPAR Archived Users Folder Termination Summary" type="html">
        <strong>The archived user deletion completed without error.  A summary is provided below.</strong><br /><br />
        #summary#
    </cfmail>
    
    Finished!
   
<cfelse> <!--- Authorization Check --->
    <cfinclude template="../Denied.cfm">    
</cfif>


<!---HTML footer, closes html and body tags.  Any footer info goes here--->
#BASE.htmlTerminationFooter()#
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
</cfoutput>